package com.itheima.mail.listener;

import com.alibaba.fastjson.JSON;
import com.itheima.utils.SmsUtils;
import lombok.SneakyThrows;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;

import java.util.Map;

//接收到发送邮件的消息之后的处理器
public class NoteListener implements MessageListener {

    @SneakyThrows
    @Override
    public void onMessage(Message message) {
        byte[] body = message.getBody();
        Map<String,String> map = JSON.parseObject(body, Map.class);
        SmsUtils smsUtils = new SmsUtils();
        System.out.println(map.get("telephone"));
        smsUtils.sendSms(map.get("telephone"),map.get("signName"),map.get("mb"),map.get("param"));
        System.out.println("短信发送成功");
    }
}
